package com.zhang.network.network;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.network.mapper.NetworkMapper;
import com.zhang.network.mapper.NetworkUserMapper;
import com.zhang.network.model.Network;
import com.zhang.network.model.NetworkUser;
import com.zhang.network.model.network.NetWorkQueryDTO;
import com.zhang.network.model.network.NetworkVo;
import org.junit.jupiter.api.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

/**
 * @author: zhangshuaiyin
 * @date: 2021/4/3 14:18
 */
@MapperScan("com.zhang.network.mapper")
@SpringBootTest
public class NetworkData {

    @Resource
    NetworkMapper networkMapper;

    @Resource
    NetworkUserMapper networkUserMapper;

    @Test
    public void add() {
        for (int i = 9; i < 13; i++) {
            Network network = new Network();
            network.setTitle("test" + i);
            network.setType("同事");
            network.setTopic("聊天");
            network.setVisible(1);
            network.setStatus(1);
            network.setUserId(3);
            networkMapper.insert(network);
        }
    }

    @Test
    public void addNetworkUser() {
        Integer networkId = 11;
        for (int i = 1; i < 4; i++) {
            NetworkUser networkUser = new NetworkUser();
            networkUser.setNetworkId(networkId);
            networkUser.setUserId(i);
            if (i == 3) {
                networkUser.setIsAdmin(1);
            } else {
                networkUser.setIsAdmin(0);
            }
            networkUserMapper.insert(networkUser);
        }
    }
}
